#ifndef B2D_FILESTREAM_H
#define B2D_FILESTREAM_H

#include "Stream.h"
#include <iostream>

NS_B2D_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief	Stream with an underlying file implementation.
////////////////////////////////////////////////////////////////////////////////////////////////////
class B2D_API FileStream :
	public Stream
{
private:
	/// File to open/close
	FILE* mFile;

public:
	FileStream(const string& path);
	virtual ~FileStream(void);

	virtual size_t getPosition(void) const;
	virtual bool isEOF(void) const;

private:
	// Stream operation implementations
	virtual void openImpl(AccessMode mode);
	virtual void closeImpl(void);
	virtual size_t seekImpl(size_t offset);
	virtual size_t skipImpl(size_t size);
	virtual size_t readImpl(void* output, size_t size);
	virtual size_t writeImpl(const void* input, size_t size);

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// \brief	Get a string representation from the access mode in order to pass it to the
	/// 		standard c i/o file handle.
	///
	/// \param	mode	The mode.
	///
	/// \return	string representation.
	////////////////////////////////////////////////////////////////////////////////////////////////////
	static const char* accessModeTostring(AccessMode mode);
};

NS_B2D_END

#endif